﻿using System;
using System.Configuration;

using DreamCube.Foundation.Basic.Utility;

namespace DreamCube.Framework.DataAccess.Basic
{
    public static class DBConnectionStringMgr
    {
        /// <summary>
        /// 从app.config中的appkeys里面反射获取连接字符串的类型，并获取连接字符串
        /// </summary>
        /// <param name="appKey"></param>
        /// <returns></returns>
        public static String GetConnectionStringByAppKey(String appKey)
        {
            String type = ConfigurationManager.AppSettings[appKey];
            IDBConnectionStringMgr connectionStr = null;
            if (MyReflection.TryCreateNewInstanceByTypeFullName(type, out connectionStr, true))
                return connectionStr.GetConnectionString();
            return String.Empty;
        }
    }
}
